//
//  MementoTest.m
//  LearnObjectiveC
//
//  Created by client on 2017/9/8.
//  Copyright © 2017年 吴可高. All rights reserved.
//

#import "MementoTest.h"
#import "Original.h"
#import "Storage.h"
#import "Memento.h"

@implementation MementoTest

-(void)mementoStorage
{
    Original * original = [[Original alloc]init];
    [original setValue:@"egg"];
    
    Storage * storage = [[Storage alloc]init];
    storage.memento = [original createMemento];
    NSString * originMsg = [NSString stringWithFormat:@"初始化状态:%@",original.value];
    NSLog(@"%@",originMsg);
    [original setValue:@"nutrition"];
    NSString * modifyMsg = [NSString stringWithFormat:@"修改之后状态:%@",original.value];
    NSLog(@"\n%@",modifyMsg);
    //回复原始状态
    [original restoreMemento:storage.memento];
    NSString * restMsg = [NSString stringWithFormat:@"恢复原始状态:%@",original.value];
    NSLog(@"\n%@",restMsg);
}
@end
